<template>
	<view id="body">
		<view class="top">
			<text class="fk">{{title}}</text>
		</view>
		<!-- 订单内容 --> 
		<view class="order-conent">
			<view>
				<text class="order-title">订单标题:</text>
				<text class="order-title-text">{{order.title}}</text>
			</view>
			<view>
				<text class="order-id">订单编号:</text>
				<text class="idtext">{{order.orderid}}</text>
				<text class="order-id-fz" @click="copy">复制</text> 
			</view>
			<view>
				<text class="order-user">创建用户:</text>
				<text class="username">{{order.issueUser}}</text>
			</view>
			<view>
				<text class="order-time">下单时间:</text>
				<text class="createtime">{{order.createTime}}</text>
			</view>
			<view>  
				<text class="zf-time">是否支付:</text>
				<text class="zftype" :style="{color:flage?'#3c9cff':'#ff5500'}">{{flagetext}}</text>
			</view> 
			<!-- 按钮 -->
			<view style="padding-bottom: 40rpx;">
				<text class="pricetext">订单金额:</text> 
				<text class="price">{{order.buytotalprice}}元</text>
			</view>
			<!-- 图片信息 -->
			<view style="padding-bottom: 20rpx;margin-left: 40rpx;margin-right: 40rpx;">
				<u-divider text="图片信息" textColor="#3c9cff" lineColor="#3c9cff"></u-divider>
			</view>
			<view class="order-imglist" style="padding-bottom: 20rpx;"> 
				<u-empty mode="data" :text="imgflagetext" v-if="imgflage"></u-empty>
				<view v-if="! imgflage">
					<image :src="item" v-if="item" mode="" class="imglist" v-for="(item,index) in imagesList" :key="item" @tap="ViewImage(index)" @longpress="deleteImg(index)"></image>
				</view>
			</view>
		</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				title:"未付款",//订单头部是否付款文字
				imagesList: [ //订单图片信息
				],
				imgflage:false,//图片是否为空
				imgflagetext:"",//图片提示文字
				flage:false,//是否支付标记
				flagetext:"未支付",//是否支付文字
				paytext:"",//是否付款提示文字
				bjIsTrue:false,//编辑1模态框标记
				bj2IsTrue:false,//编辑2模态框标记
				order: {
					orderid:"",//订单id
					contacts:"",//联系人
					contacts_phone:"",//联系人电话
					createTime:"",//订单创建时间
					address:"",//地址
					title:"", //标题
					price:"",//下单价格
					issueUser:"",//发布用户id
					ordertypeid:"",//订单所属类型id
					state:0,//订单状况
					buynum:0,//商品购买个数
					buytotalprice:0,//订单总价
					name:"",//联系人姓名
					phone:"",//联系人
					address:"",//地址信息
				} 
			}
		},
		methods: {
			onLoad(options){
				console.log("订单信息是："+options.data)
				var orderData = JSON.parse(options.data) 
				//订单图片信息
				if(orderData.orderImg == ""){
					this.imagesList = []
				}else{
					this.imagesList = orderData.orderImg.split(",") 
				}
				this.order.orderid = orderData.id
				this.order.createTime = orderData.createTime
				this.order.contacts = orderData.contacts
				this.order.contacts_phone = orderData.contactsPhone
				this.order.address = orderData.contactsAddress
				this.order.title = orderData.title
				this.order.content = orderData.content	
				this.order.bezhu = orderData.remarks 
				this.order.issueUser = orderData.issueUser
				this.order.issueUserName = orderData.issueUserName
				this.order.price = orderData.price
				this.order.ordertypeid = orderData.ordertypeid
				this.order.state = orderData.state
				this.belongUser = orderData.belongUser
				this.order.buytotalprice = orderData.buytotalprice
				this.order.buynum = orderData.buynum
				var user = uni.getStorageSync('user')
				var a = ""
				if(user){
					 a = (JSON.parse(user)).id
				}
				if(orderData.hideName == 1){
					this.order.issueUser = "匿名"
				}
				if(this.order.state != 0){
					const a = ["未付款","已付款","已接单","已完成","问题订单", "已退款"]
					this.title = a[this.order.state]
					this.flagetext = "已支付"
					this.flage= true
				}
				
			},
			//修改地址信息
			bj(){
				this.bjIsTrue = true
			},
			//地址信息修改模态框
			close(){
				this.bjIsTrue = false
			},
			// 复制订单
			copy(){
				 uni.setClipboardData({
				    data:this.order.orderid+"",
				    success: function (res) {
				        uni.getClipboardData({
				        success: function (res) {
				            uni.showToast({
				                title: "复制成功",
				                icon: 'none',
				            })
				        },
				        })
				    },
				    })
			},
			//预览图片
			ViewImage(index) {
				uni.previewImage({
					urls: this.imagesList,
					current: index
				});
			}
		}
	}
</script> 
 
<style scoped>
	@import url("../static/css/componentsCss/cart/cartOrderInfo.css");
	page {
		background-color:#f5f5f5; 
	}
</style>